{
  LW Dopetrack -- Layout Dopetrack Interface

  This header contains declarations that allow a Tool-class plug-in
  to take over most of the functionality of the Layout Dopetrack

  Based on lwdopetrack.h which is:
  Copyright 2004, NewTek, Inc.
}

{
  Copyright 2012, Jameel Halabi

  This unit is part of the BlaiseWave wrapper,
  which is licensed under the BSD 2-Clause license (see licenses/license.txt).
}

unit LW_Dopetrack;

{$mode objfpc}{$H+}

interface

uses
  LW_Types, LW_Envel;

const
  LWDOPETRACK_GLOBAL = 'Dopetrack Proxy';

  TIME_MARKER        = TLWTime(99999.0);

  // enum DTOperatingMode
  DTOPMODE_CHANNEL         = 0;
  DTOPMODE_GLOBAL          = 1;

  // enum DTEventType
  DTEVENT_KEYFUNCTION      = 0;
  DTEVENT_EDITSTATECHANGE  = 1;
  DTEVENT_BAKEZONECHANGE   = 2;
  DTEVENT_UNDO             = 3;
  DTEVENT_REDO             = 4;

  // enum DTKeyAction
  DTACTION_SELECT          = 0;
  DTACTION_SHIFT           = 1;
  DTACTION_SHIFT_COPY      = 2;
  DTACTION_CREATE_KEY      = 3;
  DTACTION_DELETE_KEY      = 4;

  // enum DTMouseEvent
  DTMOUSE_DOWN             = 0;
  DTMOUSE_MOVE             = 1;
  DTMOUSE_UP               = 2;



type

  PDTMouseParam = ^TDTMouseParam;
  TDTMouseParam = record
    Event       : Integer ; // DTMouseEvent
    Context     ,
    X           ,
    Y           ,
    W           ,
    H           ,
    Button      ,
    Count       : Integer;
  end;

  PDTKeySelect  = ^TDTKeySelect;
  TDTKeySelect  = record
    Count       : Integer;
    Indices     : PLWTime;
    Offset      : TLWTime;
  end;

  PDTBakeZone   = ^TDTBakeZone;
  TDTBakeZone   = record
    StartFrame  ,
    EndFrame    : PInteger;
    StartTime   ,
    EndTime     : PLWTime ;
    Selected    : Integer ;
  end;

  PDTEventParam = ^TDTEventParam;
  TDTEventParam = record
    Event       : Integer ; // DTEventType
    Value       : Integer ;
    Offset      : TLWTime ;
  end;

  // Menu Management Functions

  TDTMenuCount   = function
                   (      MenuID : Integer ) : Integer ;
  TDTMenuSub     = function
                   (      MenuID           ,
                          Item   : Integer ) : Integer ;
  TDTMenuSep     = function
                   (      MenuID : Integer ) : Integer ;
  TDTMenuEnable  = function
                   (      MenuID           ,
                          Item   : Integer ) : Integer ;
  TDTMenuItem    = function
                   (      MenuID           ,
                          Item   : Integer ) : PChar   ;
  TDTMenuSelect  = procedure
                   (      MenuID           ,
                          Item   : Integer ) ;
  TDTMenuInitial = function
                   ( const Void            ) : Integer ;

  // Events on the Dopetrack

  TDTUserEvent   = procedure
                   (      EventID : PDTEventParam ) ;

  TDTAllow       = function
                   (      KeyAction : Integer       ) : Integer ; // Action : DTKeyAction ;

  TDTMouse       = procedure
                   (      MouseEvnt : PDTMouseParam ) ;

  PDTMenuCallbacks = ^TDTMenuCallbacks;
  TDTMenuCallbacks = record
    MenuCount    : TDTMenuCount   ;
    MenuSubMenu  : TDTMenuSub     ;
    MenuSep      : TDTMenuSep     ;
    MenuEnable   : TDTMenuEnable  ;
    MenuItem     : TDTMenuItem    ;
    MenuSelect   : TDTMenuSelect  ;
    MenuInitial  : TDTMenuInitial ;
  end;

   PDTToolCallbacks = ^TDTToolCallbacks;
   TDTToolCallbacks = record
     UserEvent  : TDTUserEvent     ;
     Allow      : TDTAllow         ;
     MouseEvent : TDTMouse         ;
     Menu       : TDTMenuCallbacks ;
   end;

   PDTDrawFuncs = ^TDTDrawFuncs;
   TDTDrawFuncs = record
    Context    : function
                 (       Side   : Integer  ) : PInteger ; // 0=left margin, 1=right margin
    Erase       : procedure
                  (      X                 ,
                         Y                 ,
                         W                 ,
                         H      : Integer  ) ;
    Pixel       : procedure
                  (      X                 ,
                         Y                 ,
                         Color : Integer ) ; // use RGB_() to construct color
    Line        : procedure
                  (      X1                ,
                         Y1                ,
                         X2                ,
                         Y2                ,
                         Color  : Integer  ) ;
    RectOutline : procedure
                  (      X                 ,
                         Y                 ,
                         W                 ,
                         H                 ,
                         Color  : Integer  ) ;
    RectFilled  : procedure
                  (      X                 ,
                         Y                 ,
                         W                 ,
                         H                 ,
                         BColor            ,
                         FColor : Integer  ) ;
    Border      : procedure
                  (      X                 ,
                         Y                 ,
                         W                 ,
                         H      : Integer  ) ;
    Divider     : procedure
                  (      X                 ,
                         Y                 ,
                         W      : Integer  ) ;
    Text        : procedure
                  (      X                 ,
                         Y                 ,
                         Color  : Integer  ;
                   const Text   : PChar    ) ;
    TextBox     : procedure
                  (      X                 ,
                         Y                 ,
                         W                 ,
                         H      : Integer  ;
                   const Text   : PChar    ) ;
    Button      : procedure
                  (      X                 ,
                         Y                 ,
                         W                 ,
                         H                 ,
                         Color  : Integer  ) ;
    Flush       : procedure
                  (const Void              ) ;

   end;

   PLWDopetrackProxy = ^TLWDopetrackProxy;
   TLWDopetrackProxy = record
    ToolRegister       : procedure
                         (       Callbacks  : PDTToolCallbacks ) ;
    ToolRelease        : procedure
                         ( const Void                          ) ;

    ExposeEnvelopes    : procedure
                         (       EnvArray   : PLWEnvelope      ;
                           const AxisNames  : PPCHar           ;
                                 InitStates : PInteger         ) ;
    RefreshDisplay     : procedure
                         ( const Void                          ) ;

    QuerySelectedKeys  : function
                         ( const Void                          ) : PDTKeySelect ;
    QuerySelection     : procedure
                         (       Start                         ,
                                 End_       : PLWTime          ) ;

    QueryMarkers       : procedure
                         ( const Void                          ) ;
    AddMarker          : procedure
                         (       At         : TLWTime          ) ;
    RemMarker          : procedure
                         (       At         : TLWTime          ) ;

    QueryBakeZones     : function
                         ( const Void                          ) : PDTBakeZone;
    AddBakeZone        : procedure
                         (       Start                         ,
                                 End_       : TLWTime          ) ;
    RemBakeZone        : procedure
                         (       Start                         ,
                                 End_       : TLWTime          ) ;

    QueryOpMode        : function
                         ( const Void                          ) : Integer ; // Originally DTOperatingMode;

    DisplayMenu        : procedure
                         (       MenuCallbacks : PDTMenuCallbacks ) ;

    Visible            : function
                         ( const Void                          ) : Integer ;

    DrawFuncs 	       : TDTDrawFuncs ;
   end;

implementation

end.

